package com.ericzong.renamer.converter.string;

import com.ericzong.renamer.model.Record;

public class DelStringConverter extends AbstractStringConverter
{
	private int startIndex;
	private int length;
	
	public DelStringConverter()
	{
		startIndex = 0;
		length = 0;
	}

	@Override
	public void convert(Record record)
	{
		StringBuffer target = new StringBuffer(record.getSource());
		
		if(length != 0)
		{
			int start = getIndex(startIndex, target.length());
			int end = getIndex(start + length, target.length());
			target.delete(start, end);
		}
		
		record.setTarget(target.toString());
	}

	public int getStartIndex()
	{
		return startIndex;
	}

	public void setStartIndex(int startIndex)
	{
		this.startIndex = startIndex;
	}

	public int getLength()
	{
		return length;
	}

	public void setLength(int length)
	{
		this.length = length;
	}
}
